/*
 * QCAI.cpp
 *
 *  Created on: Jun 30, 2012
 *      Author: jmurray
 */

/*
  Blink
  Turns on an LED on for one second, then off for one second, repeatedly.

  This example code is in the public domain.
 */

#include <Arduino.h>
#include <Wire.h>

#include "Class/Accel.h"
#include "Class/Printf.h"

#include "helper/GlobalDefines.h"

void p(const char *fmt, ... );

#define Loops 50

Accel Acl;
unsigned long time1,time2;
int angle;

// the setup routine runs once when you press reset:
void setup() {
   // initialize the digital pin as an output.
   Serial.begin(9600);
   Acl.setTune();
   delay(1000);
   Serial.println("t,x,y,z");
   pinMode(13,OUTPUT);
}

// the loop routine runs over and over again forever:
void loop() {
   Acl.update();
   angle=asin((double)Acl.x/17500)*81;
   time1=micros();
   p("Angle: %d\r\n",angle);
   p("Time: %d(us)\n",micros()-time1);
   delay(1000);
}


